# import threading
# import time
# class Window_Thread(threading.Thread):
#     ticket_num = 10
#     lock = threading.Lock()
#
#     def run(self):
#         while True:
#             Window_Thread.lock.acquire()
#             if Window_Thread.ticket_num > 0:
#                 print(f"{self.name}正在售卖--------第{Window_Thread.ticket_num}张票")
#                 Window_Thread.ticket_num -= 1
#             Window_Thread.lock.release()
#             time.sleep(0.3)
#             if Window_Thread.ticket_num == 0:
#                 break
# if __name__ == '__main__':
#     w1 = Window_Thread(name = "窗口1")
#     w2 = Window_Thread(name = "窗口2")
#     w3 = Window_Thread(name = "窗口3")
#     w1.start()
#     w2.start()
#     w3.start()

import threading
import time
class MyThread(threading.Thread):
    nums = 10
    lock = threading.Lock()
    def run(self):
        while True:
            self.lock.acquire()
            if MyThread.nums > 0:
                print(f"{self.name}正在处理--------{self.nums}")
                MyThread.nums -= 1
            self.lock.release()
            time.sleep(0.3)
            if MyThread.nums == 0:
                break
if __name__ == '__main__':
    t1 = MyThread(name = "线程1")
    t2 = MyThread(name = "线程2")
    t1.start()
    t2.start()
    print("hello world")